import axios from 'axios'

// 获取任务列表
export function getTaskListAPI(params) {
  return axios({
    url: 'http://localhost:3001/data',
    method: 'get',
    params
  })
}

// 根据id 删除数据
export function delTaskByIdAPI(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: 'delete'
  })
}

// 新增
export function addTaskAPI(data) {
  return axios({
    url: 'http://localhost:3001/data',
    method: 'post',
    data
  })
}

// 详情
export function getTaskByIdAPI(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: 'get'
  })
}

// 修改
export function updateTaskAPI(data) {
  return axios({
    url: `http://localhost:3001/data/${data.id}`,
    method: 'put',
    data
  })
}

// 搜索
export function searchAPI(name) {
  return axios({
    url: `http://localhost:3001/data`,
    method: 'get',
    params: name
  })
}
